#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 310;
int a[N];
ll sum,cnt;
bool cmp(int x, int y)
{
	return x > y;
}
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1, cmp);
	sum = a[1] * a[1];
	int j = 1;
	int l = 2, r = n;
	while (cnt <= n - 1)
	{
		cnt++;
		if (cnt % 2 == 1)
		{
			sum += pow(a[j] - a[r], 2);
			j = r;
			r--;
		}
		else
		{
			sum += pow(a[j] - a[l], 2);
			j = l;
			l++;
		}
	}
	cout << sum << endl;
	return 0;
}